package la.bbs558.strategy.send;

import la.bbs558.entity.enums.CaptchaTypeEnum;
import la.bbs558.strategy.base.StrategyEnum;
import la.bbs558.util.JuheSendUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author: Shanks
 * @date: 2024/1/25 14:18
 * @desc:
 */
@Slf4j
@Component
public class MessageSendStrategy extends AbstractSendStrategy {

    private static final String SEND_MSG = "【558出海社区】您正在使用{}功能，验证码为：{}，请于{}分钟内完成验证。如您未使用该服务，请忽略该短信。";


    @Override
    public StrategyEnum getStrategyEnum() {
        return CaptchaTypeEnum.MESSAGE;
    }

    @Override
    protected void doHandle(SendContext context) {
        String phone = context.getTo();
        String type = context.getServerTypeEnum().getDesc();
        TimeUnit timeUnit = context.getTimeUnit();
        long time = context.getTime();
        long minutes = timeUnit.toMinutes(time);
        String code = context.getCode();
        JuheSendUtil.send(JuheSendUtil.SendTemplate.REGISTER,phone,code);
    }
}
